﻿using AJWPFAdmin.Core.Enums;
using AJWPFAdmin.Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace AJWPFAdmin.Core.TempleteSelectors
{
    public class DynamicFormSchemaTemplateSelector : DataTemplateSelector
    {
        public DataTemplate Combox { get; set; }
        public DataTemplate Date { get; set; }
        public DataTemplate TextBox { get; set; }
        public DataTemplate TextArea { get; set; }
        public DataTemplate Switch { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is DynamicFormItemSchema schema)
            {
                switch (schema.FormType)
                {
                    case VbenAdminFormType.Select:
                    case VbenAdminFormType.AutoComplete:
                        return Combox;
                    case VbenAdminFormType.Input:
                    case VbenAdminFormType.InputNumber:
                        return TextBox;
                    case VbenAdminFormType.InputTextArea:
                        return TextArea;
                    case VbenAdminFormType.Switch:
                        return Switch;
                    case VbenAdminFormType.RangePicker:
                    case VbenAdminFormType.DatePicker:
                        return Date;
                    default:
                        break;
                }
            }
            
            return TextBox;
        }
    }
}
